package file;

import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description: 字节流的read()方法及try with resource
 * User: 王圆豪
 * Date: 2025-05-10
 * Time: 17:19
 */
public class Demo8 {
    public static void main(String[] args) throws IOException {
//        File file = new File("./test.txt" );
//        System.out.println(file.createNewFile());
//        InputStream inputStream = null;
        try (InputStream inputStream = new FileInputStream("./test.txt")){
            while (true) {
                int data = inputStream.read();
                if (data == -1) break;
                System.out.println(data);
            }
        }

//        try{
//            while (true) {
//                int data = inputStream.read();
//                if (data == -1) break;
//                System.out.println(data);
//            }
//        }finally {
//            inputStream.close();
//        }
    }
}
